public class Cuboid {
    private double length, width, heigth;//私有成员变量
    public Cuboid(){};//空构造方法
    public Cuboid(double x, double y, double z)
    {
        setLength(x);
         setWidth(y);
        setHeigth(z);
    }
    public void setLength(double a)
    {
        if(a > 0)
            this.length = a;
        else
            System.out.println("长度必须大于0");
    }
    public void setWidth(double a)
    {
        if(a > 0)
            this.width = a;
        else
            System.out.println("宽度必须大于0");
    }
    public void setHeigth(double a)
    {
        if(a > 0)
            this.heigth = a;
        else
            System.out.println("高度必须大于0");
    }
    //输入字符l,w,h获取相应信息
    public double getInfo(char a)
    {
        if(a == 'l')
            return this.length;
        else if(a == 'w')
            return this.width;
        else if(a == 'h')
            return this.heigth;
        else
            return 0.0;
    }
    //计算表面积
    public double getArea()
    {
        return 2 * (length * width + length * heigth + width * heigth);
    }
    //计算体积
    public double getCubage()
    {
        return (length * width * heigth);
    }
    //打印
    public void printCuboid()
    {
        System.out.println("该长方形的长为：" + this.length);
        System.out.println("该长方形的宽为：" + this.width);
        System.out.println("该长方形的高为：" + this.heigth);
    }
    //判断正方体
    public void isCube(double x, double y, double z)
    {
        if(x == y && x == z)
            System.out.println("该长方体是正方体");
        else
            System.out.println("该成方体不是正方体");
    }
    public void drawing()
    {
        System.out.println("绘制图形成功");
    }
    public static void main(String[] args) {
        /*Cuboid cuboidA = new Cuboid(1.5,1.6,18.6);
        cuboidA.printCuboid();
        cuboidA.isCube(1.5, 1.6, 18.6);
        cuboidA.drawing();*/

        Cuboid cuboidB = new Cuboid(2.5, 6.8, 8.0);
        cuboidB.printCuboid();
        System.out.println("更改后：");
        cuboidB.setLength(4.6);
        cuboidB.printCuboid();
        System.out.println("该长方体表面积为 S = " + cuboidB.getArea());
        System.out.println("该长方体体积为 V = " + cuboidB.getCubage());
    }

}
